package com.shadow.bus.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.graphics.drawable.VectorDrawableCompat;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.shadow.bus.entity.AlarmInfoEntity;

import java.util.List;

import busfix.tepth.com.shadow_bus.R;

/**
 * @author zhangyu
 * @date 2018/7/11
 */

public class AlarmAdapter extends BaseQuickAdapter<AlarmInfoEntity, BaseViewHolder> {
    VectorDrawableCompat mCompatLevel1;
    VectorDrawableCompat mCompatLevel2;
    VectorDrawableCompat mCompatLevel3;

    public AlarmAdapter(Context context, int layoutResId, @Nullable List<AlarmInfoEntity> data) {
        super(layoutResId, data);
        mCompatLevel1 = VectorDrawableCompat.create(context.getResources(),
                R.drawable.ic_warning_level_3_24dp, context.getTheme());
        mCompatLevel2 = VectorDrawableCompat.create(context.getResources(),
                R.drawable.ic_warning_level_2_24dp, context.getTheme());
        mCompatLevel3 = VectorDrawableCompat.create(context.getResources(),
                R.drawable.ic_warning_level_1_24dp, context.getTheme());

    }

    @Override
    protected void convert(BaseViewHolder helper, AlarmInfoEntity item) {
        switch ((int) item.getLevel()) {
            case 1:
                helper.setImageDrawable(R.id.iv_alarm, mCompatLevel1);
                break;
            case 2:
                helper.setImageDrawable(R.id.iv_alarm, mCompatLevel2);
                break;
            case 3:
                helper.setImageDrawable(R.id.iv_alarm, mCompatLevel3);
                break;
        }
        helper.setText(R.id.tv_alarm_name, item.getName());
        helper.setText(R.id.tv_alarm_time, "开始时间:" + item.getStartTimeStr()
                + " 结束时间:" + item.getEndTimeStr());
        helper.setText(R.id.tv_alarm_des, item.getMsg());
    }
}
